/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dds2.serviceSystem.Bl;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import mx.its.dds2.ServicesSystem.Enum.TransactionState;
import mx.its.dds2.ServicesSystem.Modelo.Usersystem;
import mx.its.dds2.serviceSystem.Dao.UsersystemDaoLocal;

/**
 *
 * @author Carlos Asis
 */
@Stateless
public class UserSystemBl implements UserSystemBlLocal {

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

     @EJB
    private UsersystemDaoLocal usersystemDao;

  

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @Override
    public void register(Usersystem user) {
       
            usersystemDao.create(user);

    }

    @Override
    public TransactionState modify(Usersystem user) {
        if (user.getId() == null || usersystemDao.find(user.getId()) == null) {
            return TransactionState.INCOMPLETE;
        } else {
            usersystemDao.edit(user);
            return TransactionState.COMPLETE;
        }
    }

    @Override
    public TransactionState delete(Usersystem user) {
        if (user.getId() == null || usersystemDao.find(user.getId()) == null) {
            return TransactionState.INCOMPLETE;
        } else {
            usersystemDao.remove(user);
            return TransactionState.COMPLETE;
        }
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @Override
    public List<Usersystem> getListAll() {
        return usersystemDao.findAll();
    }
}
